package com.hm.demo;

import java.util.ArrayList;

public class Operator1 implements StudentOperator {
    @Override
    public void printAll(ArrayList<Student> stus) {
        int count1=0;
        int count2=0;
        for (Student student : stus) {
            System.out.println(student);
            if(student.getSex()=='男'){
                count1++;
            }else{
                count2++;
            }
        }
        System.out.println(count1+"左男右女"+count2);
    }

    @Override
    public void printAvg(ArrayList<Student> stus) {
        double sum=0;
        int count=0;
        double maxSc=stus.getFirst().getScore();
        double minSc=stus.getFirst().getScore();
        for (Student student : stus) {
            if(maxSc<student.getScore()){
                maxSc=student.getScore();
            }
            if(minSc>student.getScore()){
                minSc=student.getScore();
            }
            sum+=student.getScore();
            count+=1;
        }
        System.out.println(sum/count);
        System.out.println("最高分"+maxSc);
        System.out.println("最低分"+minSc);
    }
}
